package unit04.day04;

/**
 *static Thread currentThread()
 *获取运行当前方法的线程
 */
public class ThreadDemo4 {

	public static void main(String[] args) {
		Thread main = Thread.currentThread();
		System.out.println("运行main方法的线程是:"+main);
		dosome();
		
		Thread t = new Thread() {
			public void run() {
				Thread t = Thread.currentThread();
				System.out.println("自定义线程:"+t);
				dosome();
			}
		};
		t.start();
		System.out.println(t.getId());
		System.out.println(t.getName());
		System.out.println(t.getState());
		System.out.println(t.isDaemon());//是否为守护线程
		System.out.println(t.isInterrupted());//是否中断
		
	}
	
	
	
	public static void dosome() {
		Thread t = Thread.currentThread();
		System.out.println("运行dosome方法的线程是:"+ t);
	}
}
